package miniBanco.Gui;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.*;
import miniBanco.Handler.*;
public class MenuFrame extends JFrame {
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	MenuFrame instance;
    JMenuBar JMenuBar;
    JMenu JMenuFile;
    Container contenedor;
    public BorderLayout layout;
    /**
     * The constructor.
     */  
     public MenuFrame()
     {
    	instance = this;

    	 
    	setBounds(0,0,800,600);
    	
    	layout = new BorderLayout();
 		setLayout(layout);
    	setTitle("Sistema de Gestion MiniBanco by Martin Vecchione");
        
 		JMenuBar = new JMenuBar();         
   	 	JMenuFile = new JMenu("File");
     	JMenuItem JMenuFileExit = new JMenuItem("Salir");
    	setJMenuBar(JMenuBar);
    	JMenuBar.add(JMenuFile);
     	JMenuFile.add(JMenuFileExit);
    	setSize(new Dimension(400, 400));
        // Add action listener.for the JMenu button
        JMenuFileExit.addActionListener
        (
            new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                	MenuFrame.this.windowClosed();
                }
            }
        ); 
        // Add window listener.
        this.addWindowListener
        (
            new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                	MenuFrame.this.windowClosed();
                }
            }
        );  
    }
     
     public void SetUpForUsuario()
     {
         JMenu editMenu = new JMenu("Tablas");
         JMenuItem ClientesItem = new JMenuItem("Clientes");
         ClientesItem.addActionListener(
                 new ActionListener() {
                     public void actionPerformed(ActionEvent e) {
                     	//HandlerClientes handler = new HandlerClientes(instance);
                     	//handler.onItemClick();
                     }
                 }
             );
         
         JMenuItem UsuariosItem = new JMenuItem("Usuarios");  
         UsuariosItem.addActionListener(
                 new ActionListener() {
                     public void actionPerformed(ActionEvent e) {
                      	HandlerUsuarios.getInstance().onItemClick();
                     }
                 }
             );
         
         JMenuItem ErroresItem = new JMenuItem("Ver Errores");  
         ErroresItem.addActionListener(
                 new ActionListener() {
                     public void actionPerformed(ActionEvent e) {
                     	HandlerErrores.getInstance().OpenErroresPopup();
                     }
                 }
             );
         
         JMenuItem LogItem = new JMenuItem("Ver Log");  
         LogItem.addActionListener(
                 new ActionListener() {
                     public void actionPerformed(ActionEvent e) {
                     	HandlerLog.getInstance().OpenLogPopup();
                     }
                 }
             );
         
        JMenu ConfMenu = new JMenu("Configuracion");
      	ConfMenu.add(UsuariosItem);
         JMenu AdmMenu = new JMenu("Administrador");

 
     	editMenu.add(ClientesItem);
     	AdmMenu.add(ErroresItem);    	
     	AdmMenu.add(LogItem);    	
     	
 
     	JMenuBar.add(editMenu);
     	JMenuBar.add(AdmMenu);
     	JMenuBar.add(ConfMenu);

     }
    /**
     * Shutdown procedure when run as an application.
     */
    protected void windowClosed() {
        System.exit(0);
    }
}